package orest.front.collection;

import java.sql.Connection;

import net.ssta.common.LoginUser;
import net.ssta.core.base.SQLBuilderBase;
import net.ssta.core.web.RequestKit;



/**
 * 
 * @ClassName:
 * @Description: 
 * @author: 
 * @date: 
 * 
 */
public class CollectionSql extends SQLBuilderBase
{
    /*
     * m_builder : 单例实例
     */
    private static CollectionSql m_builder = new CollectionSql();
    
    /**
     * @Title: getSQLBuilder
     * @Description: 获取实例
     * 
     * @param conn 数据库连
     * @return 单例实例
     */
    public static CollectionSql getSQLBuilder(Connection conn)
    {
        return m_builder;
    }
    
    /**
     * 获取指定用户的收藏信息
     * 
     * @param RequestKit
     * @return
     */
    public static String getCollectionByUseridSql()
    {
        StringBuffer sb = new StringBuffer();
        sb.append("SELECT * FROM T_MYCOLLECTION T WHERE USERID = '").append(LoginUser.getUserId()).append("' ORDER BY COLLECTIONDATE DESC");
        //sb.append("SELECT * FROM T_USERMESSAGE T WHERE USERID = '1' ORDER BY SUBMITDATE DESC");
        return sb.toString();
    }
    
    /**
     * 获取指定用户、某个信息分类的收藏信息
     * 
     * @param RequestKit
     * @return
     */
    public static String getCollectionByClassUseridSql(String columnid)
    {
        StringBuffer sb = new StringBuffer();
        sb.append("SELECT * FROM T_MYCOLLECTION T WHERE USERID = '").append(LoginUser.getUserId()).append("' AND COLUMNID in (").append(columnid).append(") ORDER BY COLLECTIONDATE DESC");
        //sb.append("SELECT * FROM T_USERMESSAGE T WHERE USERID = '1' ORDER BY SUBMITDATE DESC");
        return sb.toString();
    }
    
    /**
     * 删除用户收藏信息的sql
     * 
     * @param uuid:用户收藏的唯一标识
     * 
     * @return：
     */
    public static String deleteCollectionSql(String uuid)
    {
        StringBuffer sb = new StringBuffer();
        sb.append(" DELETE FROM T_MYCOLLECTION WHERE ID ='").append(uuid).append("' ");
        return sb.toString();
    }
    
    /**
     * 根据用户收藏uid获取详细信息
     * 
     * @param uuid:用户收藏的唯一标识
     * 
     * @return：sql字符串
     */
    public static String getCollectionInfoSql(String uuid)
    {
        StringBuffer sb = new StringBuffer();
        sb.append(" SELECT * FROM T_MYCOLLECTION WHERE ID ='").append(uuid).append("' ");
        return sb.toString();
    }
    
    
    
}
